<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html style="height:100%">
    <head>
        <title>url资源管理</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" type="text/css" href="../resource/js/easyui/themes/default/easyui.css">
        <link rel="stylesheet" type="text/css" href="../resource/js/easyui/themes/icon.css">
        <link rel="stylesheet" type="text/css" href="../resource/js/easyui/themes/color.css">

        
        <script src="../resource/js/easyui/jquery.min.js" type="text/javascript"></script>
        <script src="../resource/js/easyui/jquery.easyui.min.js" type="text/javascript"></script>
       <!-- <script src="../resource/js/easyui/easyloader.js" type="text/javascript"></script>-->   
        <script src="../resource/js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
     
     
        <style type="text/css">
            #fm{
                margin:0;
                padding:10px 30px;
            }
            .ftitle{
                font-size:14px;
                font-weight:bold;
                padding:5px 0;
                margin-bottom:10px;
                border-bottom:1px solid #ccc;
            }
            .fitem{
                margin-bottom:5px;
            }
            .fitem label{
                display:inline-block;
                width:80px;
            }
            .fitem input{
                width:160px;
            }
        </style>

        <script type="text/javascript" >
            
            /*
             查询函数
            */
            function  query(){

                
                var params ="";

   
                

                            var name = $('#qname').textbox("getValue") ;
                            if(name && name !== ""){
                                params += '&name='+name;
                            }
                            
               
               
                            
        

                            var code = $('#qcode').textbox("getValue") ;
                            if(code && code !== ""){
                                params += '&code='+code;
                            }
                            
               
               
                            
        

                            var describ = $('#qdescrib').textbox("getValue") ;
                            if(describ && describ !== ""){
                                params += '&describ='+describ;
                            }
                            
               
               
                            
        

                            var parent = $('#qparent').combobox("getValue") ;
                             if(parent && parent !== ""){
                                params += '&parent.id='+parent;
                             }
                            
               
               
                            
        

                            var url = $('#qurl').textbox("getValue") ;
                            if(url && url !== ""){
                                params += '&url='+url;
                            }
                            
               
               
                            
        

                $('#dg').datagrid({url: '../api/UrlResource?id='+params, method: 'get'});

                $('#dg').datagrid('reload');
            }
            
            
            
            function newUrlResource() {
                
                $('#dlg').dialog('open').dialog('setTitle', '新建url资源');
                $('#fm').form('clear');
                
                url = '../api/UrlResource';

            }

            function saveUrlResource() {
                $('#fm').form('submit', {
                    url: url,
                    method:'post',
                    onSubmit: function () {
                        return $(this).form('validate');
                    },
                    success: function (result) {
                        var result = eval('(' + result + ')');
                        if (!result.success) {
                            $.messager.show({
                                title: '出错',
                                msg: result.msg
                            });
                        } else {
                            $('#dlg').dialog('close');        // close the dialog
                            $('#dg').datagrid('reload');    // reload the user data
                        }
                    }
                });
            }

            function editUrlResource() {

                var row = $('#dg').datagrid('getSelected');
                if (row) {
                    $('#dlg').dialog('open').dialog('setTitle', '编辑url资源');
                    $('#fm').form('load', row);
                   url = '../api/UrlResource/' + row.id+'?_method=PUT';


                   
                      
                   
                }
            }

            function destroyUrlResource() {
                var row = $('#dg').datagrid('getSelected');
                if (row) {
                    
                                        
                    $.messager.confirm('确认提示', '你确定要删除此url资源吗?', function (r) {
                        if (r) {
                            $.post('../api/UrlResource/' + row.id, {'_method':'DELETE'}, function (result) {
                                if (result.success) {
                                    $('#dg').datagrid('reload');    // reload the user data
                                } else {
                                    $.messager.show({// show error message
                                        title: '删除失败',
                                        msg: result.msg,
                                        icon:'error'
                                    });
                                }
                            }, 'json');
                        }
                    });
                }
            }
           

                

                

                

                
                
                    function  formatParent(value,rec){
               
                        if(rec.parent){
                            return rec.parent.name; 
                        }
               
           
                    }

                
       
          
        </script>
    </head>
    <body style="height:100%">

        <table id="dg" title="url资源信息" class="easyui-datagrid" style="width:100%;height:100%"
               url="../api/UrlResource" method="get"
               toolbar="#toolbar"  pagination="true" 
               rownumbers="true" fitColumns="true" singleSelect="true">
            <thead>
                <tr>
                    <th field="id" width="50" hidden="true">ID</th>
                    <th field="name" width="30" data-options="sortable:true"> 名称</th> 
                    <th field="code" width="30" data-options="sortable:true"> 编码</th> 
                    <th field="describ" width="30" data-options="sortable:true"> 描述</th> 
                    <th field="parent" width="100" data-options="sortable:true, formatter:formatParent"> 父资源</th>
                    <th field="url" width="30" data-options="sortable:true"> 地址</th> 

                </tr>
            </thead>
        </table>

        <div id="toolbar">
            <!--  查询条件选择区 -->
                



                <label>名称:</label> 
                    
                    <input  id="qname" name="name" class="easyui-textbox"    style="width:80px;">


                <label>编码:</label> 
                    
                    <input  id="qcode" name="code" class="easyui-textbox"    style="width:80px;">


                <label>描述:</label> 
                    
                    <input  id="qdescrib" name="describ" class="easyui-textbox"    style="width:80px;">


                <label>父资源:</label> 
                    

                    <input  id="qparent" name="parent.id" class="easyui-combobox"    style="width:80px;" data-options="
                     url:'../api/resource/all',
                    method:'get',
                    panelHeight:'auto',        
                    valueField: 'id',
                    textField: 'name',
                    
                    ">


                <label>地址:</label> 
                    
                    <input  id="qurl" name="url" class="easyui-textbox"    style="width:80px;">


            
                
                
                
            <a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="query()">查询</a>
            <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUrlResource()">新建</a>
            <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUrlResource()">编辑</a>
            <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUrlResource()">删除</a>
        </div>

        <!--  编辑 对话框 -->      
        <div id="dlg" class="easyui-dialog" style="width:700px;height:450px;padding:10px 20px"
             closed="true" buttons="#dlg-buttons">
            <div class="ftitle">url资源信息编辑</div>
            <form id="fm" method="post">


                    
                    
                    <div class="fitem" style="float:left">
                    <label>名称:</label>
                    <input name="name" class="easyui-textbox" >
                    </div>
                    
                    
                    <div class="fitem" style="float:right">
                    <label>编码:</label>
                    <input name="code" class="easyui-textbox" >
                    </div>
                    
                    
                    <div class="fitem" style="float:left">
                    <label>描述:</label>
                    <input name="describ" class="easyui-textbox" >
                    </div>
                    
                    
                    <div class="fitem" style="float:right">
                     <label>父资源:</label> 
                    <input  id="parent" name="parent.id" class="easyui-combobox"  class="fitem"   data-options="
                     url:'../api/resource/all',
                    method:'get',
                    panelHeight:'auto',        
                    valueField: 'id',
                    textField: 'name',
                    
                    ">
                    </div>
                    
                    
                    <div class="fitem" style="float:left">
                    <label>地址:</label>
                    <input name="url" class="easyui-textbox" >
                    </div>



            </form>
        </div>
        <div id="dlg-buttons">
            <a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUrlResource()">保存</a>
            <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
        </div>


    </body>
</html>
